<template>
  <div>
    <div class="title">
      北部湾港通船舶经纪有限公司管理后台
    </div>
    <el-form :model="formdata" status-icon  ref="formdata" label-width="40px" class="login-box">
      <el-form-item label="邮箱" prop="age">
        <el-input size="small" v-model="formdata.email"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="checkPass">
        <el-input size="small" type="password" v-model="formdata.password" auto-complete="off"></el-input>
      </el-form-item>
    </el-form>
    <div class="center">
      <el-button size="small" type="primary" @click="onLogin">登录</el-button>
    </div>
  </div>
</template>

<script>
    import api from '../utils/api'
    import {get, post} from '../utils/request'
export default {
    data(){
        return {
            formdata:{
                email:'',
                password:''
            }
        }
    },
    props: {
    },
    mounted(){
    },
    methods:{
        onLogin(){
            let {email,password} = this.formdata
            post(api.login,{
                email,password
            }).then(res=>{
                // this.isLogin =true
                let {token,email} = res
                localStorage.setItem('token',token)
                localStorage.setItem('email',email)
                window.location.reload()
            }).catch(err=>{
                this.$message({
                    type: 'info',
                    message: err.msg
                });
            })
        },
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
  .title{
    text-align: center;
    font-size: 30px;
    padding-top: 10%;
  }
  .login-box{
    margin: 0 auto;
    width: 240px;
    margin-top: 60px;
  }
  .center{
    text-align: center;
  }
</style>
